<?php

namespace Ignus\View\Node\Expression;

use Ignus\View\Node\Expression;
use Ignus\View\Compiler;
use Ignus\View\NodeInterface;

abstract class Binary extends Expression
{
    public function __construct(NodeInterface $left, NodeInterface $right, $lineno)
    {
        parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
    }

    public function compile(Compiler $compiler)
    {
        $compiler
            ->raw('(')
            ->subcompile($this->getNode('left'))
            ->raw(' ');

        $this->operator($compiler);

        $compiler
            ->raw(' ')
            ->subcompile($this->getNode('right'))
            ->raw(')');
    }

    abstract public function operator(Compiler $compiler);
}
